package controller;

import com.google.gson.Gson;
import model.ResponseMessage;
import model.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(urlPatterns = "/user/login")
public class LoginController extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       String username= request.getParameter("username");
        User user = new User();
        user.setUsername(username);

        Gson gson =new Gson();
        ResponseMessage responseMessage = new ResponseMessage();

        responseMessage.setFlag(true);
        responseMessage.setUser(user);

        PrintWriter out = response.getWriter();
        out.println(gson.toJson(responseMessage));
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
